package com.bj58.ecdata.dashboard.constant;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.bj58.ecdata.dashboard.dbentity.InfoResume_age;
import com.bj58.ecdata.dashboard.dbentity.InfoResume_salary;

public final class InfoConst {
	
	private static Map<String, JSONArray> businessCateMap = new HashMap<String, JSONArray>();
	private static Map<String, JSONArray> postRateCateMap = new HashMap<String, JSONArray>();
	private static Map<String, JSONArray> resumeCrowdMap = new HashMap<String, JSONArray>();
	public static final  JSONArray resumeCateList= JSON.parseArray("['销售', '普工/技工', '餐饮', '人事/行政/后勤', '司机/交通服务', '超市/百货/零售', '物流/仓储', '教育培训', '客服', '财务/审计/统计', '建筑', '家政保洁/安保', '淘宝职位', '美容/美发', '医院/医疗/护理', '酒店/旅游', '娱乐/休闲', '传单派发', '计算机/互联网/通信', '美术/设计/创意', '汽车制造/服务', '促销/导购', '贸易/采购', '服务员', '生产管理/研发', '金融/银行/证券/投资', '市场/公关/媒介']");
	
	static{
		businessCateMap.put("zhaopin" ,JSONArray.parseArray("['普工/技工','物流/仓储','人事/行政/后勤','销售','家政保洁/安保','其他职位','司机','餐饮','超市/百货/零售','客服','美容/美发','美术/设计/创意','计算机/互联网/通信','财务/审计/统计','教育培训','贸易/采购','生产管理/研发','电子/电气','建筑']"));
		businessCateMap.put("fangchan", JSONArray.parseArray("['二手房','租房','商铺租售/生意转让','写字楼','合租房','短租房/日租房','厂房/仓库/土地','求租房']"));
		businessCateMap.put("huangye",JSONArray.parseArray("['家装服务','搬家','建材','保洁清洗','保姆/月嫂','二手回收','工装服务','家电维修','电脑维修','管道疏通','租车','职业技能培训','婚庆','工商注册','房屋维修/防水']"));
		businessCateMap.put("ershou",JSONArray.parseArray("['手机号码','自行车/电动车','二手摩托车','二手手机','二手家电','二手家具','办公用品/设备','宠物狗','二手设备','服装/鞋帽/箱包','台式机/配件']"));
		businessCateMap.put("ershouchuangxin",JSONArray.parseArray("['二手回收','手机号码','办公用品/设备','宠物狗','二手设备']"));
		businessCateMap.put("ershoutuiguang",JSONArray.parseArray("['二手手机','台式机/配件','二手家电','服装/鞋帽/箱包','自行车/电动车','二手家具','二手摩托车']"));
		businessCateMap.put("ershouche",JSONArray.parseArray("['二手汽车求购','二手汽车转让','急求急售','车辆配件']"));
		businessCateMap.put("total",JSONArray.parseArray("['招聘','黄页','房产','二手','二手车','二手创新','二手推广']"));
		
		postRateCateMap.put("招聘" ,JSONArray.parseArray("['全职招聘','兼职招聘']"));
		postRateCateMap.put("房产", JSONArray.parseArray("['租房','二手房','出租','合租房','求租房','短租房/日租房','商铺租售/生意转让','写字楼','厂房/仓库/土地/车位','新房']"));
		postRateCateMap.put("黄页",JSONArray.parseArray("['丽人','休闲娱乐','农林牧副渔','医疗健康','商务服务','婚庆摄影','家政服务','批发采购','招商加盟','教育培训','旅游酒店','汽车服务','装修建材','餐饮美食']"));
		postRateCateMap.put("二手",JSONArray.parseArray("['二手市场','二手手机','宠物','票务','车辆买卖与服务']"));
		postRateCateMap.put("二手车",JSONArray.parseArray("['二手车','二手汽车求购','急求急售','汽车配件']"));
		businessCateMap.put("二手创新",JSONArray.parseArray("['二手回收','手机号码','办公用品/设备','宠物狗','二手设备']"));
		businessCateMap.put("二手推广",JSONArray.parseArray("['二手手机','台式机/配件','二手家电','服装/鞋帽/箱包','自行车/电动车','二手家具','二手摩托车']"));

		resumeCrowdMap.put("age",JSONArray.parseArray("['16以下','16-20','21-30','31-40','41-50','50以上']"));
		resumeCrowdMap.put("education",JSONArray.parseArray("['高中以下','高中','中专/技校','大专','本科','硕士','博士','MBA/EMBA']"));
		resumeCrowdMap.put("salary_name",JSONArray.parseArray("['面议','1000以下','1000-2000','2000-3000','3000-5000','5000-8000','8000-12000','12000-20000','20000-25000','25000以上']"));
		resumeCrowdMap.put("work_years",JSONArray.parseArray("['应届生','1年以下','1-3年','3-5年','5-10年','10年以上','不限']"));
	}
	
	public static List<Object> getCrowdCateList(String type){
		return resumeCrowdMap.get(type);
	}
	
	public static List<Object> getCateListByBusiness(String businessName){
		return businessCateMap.get(businessName);
	}
	
	public static List<Object> getPostRateCateList(String businessName){
		return postRateCateMap.get(businessName);
	}

	private static final String COLS_PTN = "%s,sum(info_valid_add_count)/count(distinct stat_date) as info_valid_add_count, sum(user_valid_add_count)/count(distinct stat_date) as user_valid_add_count";
	private static final String CON_PTN = "business_name='%s' AND cate1_name='all' AND user_type_name='all' group by %s";

	/**
	 * 获取信息量总体趋势图查询列
	 * @author zhaoxiang 2015-07-21
	 */
	public static String getLineCols(String dateGroup) {
		return String.format(COLS_PTN, dateGroup);
	}
	
	/**
	 * 获取信息量总体趋势图查询条件
	 * @author zhaoxiang 2015-07-21
	 */
	public static String getLineCon(String businessName, String dateGroup) {
		return String.format(CON_PTN,businessName, dateGroup);
	}
	
	
	private static final String UserType_COLS_PTN = "%s,%s,sum(%s)/count(distinct stat_date) as %s";
	private static final String UserType_CON_PTN = "business_name='%s' AND cate1_name='all' AND user_type_name!='all' group by %s,user_type_name";
	
	/**
	 *  个人，免费商家，VIP 趋势图查询列
	 * @author zhaoxiang 2015-07-21
	 */
	public static String getUserTypeCols(String indexType,String keyCol,String dateGroup) {
		return String.format(UserType_COLS_PTN,dateGroup,keyCol, indexType,indexType);
	}
	
	/**
	 *  个人，免费商家，VIP 趋势图查询条件
	 * @author zhaoxiang 2015-07-21
	 */
	public static String getUserTypeCon(String businessName, String dateGroup) {
		return String.format(UserType_CON_PTN,businessName, dateGroup);
	}
	
	
	private static final String userTypeSrc_COLS_PTN = "%s,%s,sum(info_valid_add_count)/sum(user_valid_add_count) as %s";
	
	/**
	 *  个人，免费商家，VIP 趋势图查询列
	 * @author zhaoxiang 2015-07-21
	 */
	public static String getUserTypeSrcCols(String dateGroup,String keyCol,String userType) {
		return String.format(userTypeSrc_COLS_PTN, userType, dateGroup);
	}

	
	private static final String SOURCE_PIE_CON = "stat_date ='%s'  AND stat_type='day' AND cate2_name='all' AND user_type_name='%s' AND platform!='all' GROUP BY platform,source_name";
	
	public static String getSourceTwoPieCon(String beginDate,String userType){
		return String.format(SOURCE_PIE_CON, beginDate,userType);
	}
	
	
	
	public static Class<?> getResumeBeanClass(String indexType){
		if(StringUtils.equalsIgnoreCase(indexType, "age") || StringUtils.equalsIgnoreCase(indexType, "education")){
			return InfoResume_age.class;
		}else if(StringUtils.equalsIgnoreCase(indexType, "work_years") || StringUtils.equalsIgnoreCase(indexType, "salary_name")){
			return InfoResume_salary.class;
		}else{
			return null;
		}
	}
}
